let { writeFile } = require('fs/promises');


const { datadb } = require('./db.js');
let cities = [];
function readname(db, res) {
  db.forEach((element) => {
    let { children, name } = element;

    if (name && !name.endsWith('区')) {
      res.push(name);
    }
    if (Array.isArray(children)) {
      readname(children, res);
    }
  });
}

function main (){
    readname(datadb,cities);
    writeFile('output.json', JSON.stringify(cities, null, '  '), {
        encoding: 'utf8',
      }).then((res) => {});
}

main();